package com.fatcat.easybuy.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author 郝秦毅
 * @since 2025/9/10 11:52
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(true)//是否启用Swagger
                .select()//扫描接口
                .apis(RequestHandlerSelectors.basePackage("com.fatcat.easybuy.controller"))//RequestHandlerSelectors配置扫描的接口
                .paths(PathSelectors.any()) //PathSelectors配置扫描的路径
                .build()
                ;
    }


    //配置文档信息
    public ApiInfo apiInfo() {
        Contact contact = new Contact("Fatcat", "https://www.Fatcat.com", "fatcat@qq.com");
        return new ApiInfoBuilder()
                .title("接口文档")
                .description("pageDemo接口文档")
                .termsOfServiceUrl("https://www.Fatcat.com")
                .contact(contact)
                .version("1.0")
                .build();
    }
}
